// 废气治理设施点检相关 API 封装
// 参考小程序 pages/form-manager/facility-check/air/index.js 逻辑
import { get, post } from './index'

// 获取废气点检详情
export const getAirDetail = (id) => get(`/api/form/bizFacilityCheckAir/get/${id}`)

// 获取排扣(排放口)列表
// pollutionSourceId: 企业污染源 ID
// outletCategory: 排扣类别 (字典 ZQT_FQPKLX)
export const getOutlets = (pollutionSourceId, outletCategory) => {
	return post(`/api/bizPollutionSourceInfo/outlet/${pollutionSourceId}`, { outletCategory })
}

// 获取最近一次实时监测数据 (用于填充日均值等)
// outletCode: 排扣编号
// factorCodes: 污染因子代码数组
export const getLastDayMonitorData = (outletCode, factorCodes = []) => {
	return post(`/api/form/thirdPartMonitor/lastRealMonitorData`, {
		monitoringType: '02', // 废气监测类型
		outletNo: outletCode,
		igCodes: factorCodes,
	})
}

// 获取最近10天的上报记录 (用于一键填充)
export const getNearData = (beginTime, pollutionSourceId) => {
	return post(`/api/form/bizFacilityCheckAir/getNearData`, {
		beginTime,
		pollutionSourceId,
	})
}

// 新增废气点检记录
export const addAirCheck = (formData) => post(`/api/form/bizFacilityCheckAir/add`, formData)

export default {
	getAirDetail,
	getOutlets,
	getLastDayMonitorData,
	getNearData,
	addAirCheck,
}
